<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="layout">
<head>
<title>秒杀团购商品管理</title>
 <script th:inline="javascript">
/*<![CDATA[*/

    function add(event,element){
    	event.preventDefault();
    	var re = /^[0-9]+.?[0-9]*$/; 
    	var regex = /^\d{0,9}$/;
    	var reprice = /^\d{1,10}(\.\d{1,2})?$/;
    		
   		var _id = $(element).attr("href").split("_")[0];
   		var _price = $("#secKillGroupBuyPrice"+_id).val();
   		var _number = $("#secKillGroupBuyNumber"+_id).val();
   		var _skgbid = $(element).attr("href").split("_")[1];
   		var _viewState=$("#hidden_viewState").val();

   		if(_price=='' || _price <= 0){
   			alert("活动价格不能小于0");return;
   		}else if(_number=='' || _number <= 0){
   			alert("限购数量不能小于0");return;
   		}else if(!re.test(_number) || !regex.test(_number)){
   			alert("请输入正确且不超过10位的限购数量");return;
   		}else if(!reprice.test(_price)){
   			alert("请输入正确且不超过10位的促销价格");return;
   		}
   		$.ajax({
            url: '/promotion/seckillgroupbuygoods/checkGood',
            type: 'post',
            data: {'id': _id},
            contentType: "application/x-www-form-urlencoded; charset=utf-8",
            error: function () {
                alert('出错');
            },
            success: function (data) {
				if(data==1){
					alert("该商品已在其他正在进行或者即将开始的活动中了");
					return;
				}else{
					BOSS.remoteCall('promotion/seckillgroupbuygoods/ajaxsave',$('#div_goods_grid'),{id:_id,number:_number,price:_price,skgbid:_skgbid,viewState:_viewState,spadd:'spadd'});
				}
            }
        });	
    }
    
    function del(event,element){
    	event.preventDefault();
      	bootbox.confirm("您确定删除吗?", function(result) {
    	if(result){
    		var _id = $(element).attr("href").split("_")[0];
    		var _skgbid = $(element).attr("href").split("_")[1];
    		var _page=$(element).attr("href").split("_")[2];
    		var _viewState=$("#hidden_viewState").val();
    		BOSS.remoteCall('promotion/seckillgroupbuygoods/deletegood',$('#div_goods_grid'),{goodsId:_id,skgbid:_skgbid,page:_page,viewState:_viewState});
    		}
    	}); 
    }
	
/*]]>*/
</script>
</head>
<body>
<div layout:fragment="content">
	<div class="row">
		<div class="col-md-12">
			<div class="btn-group pull-right">
				<a href="index.html" th:href="@{'/promotion/seckillgroupbuygoods/index/'+${secKillGroupBuyId}}" id="sample_editable_1_new" class="btn green">返回<i class="fa fa-arrow-circle-o-left"></i></a>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-12">
			<div class="form">
					<h4 class="form-section">秒杀团购商品信息</h4>
					<input id="hidden_viewState" type="hidden" name="viewState"
                           th:value="${viewState}"/>
					<div class="form-body">
					<div class="col-md-15 col-sm-13">
						<form class="form-inline" style="float:left;margin-right:50px;" th:action="@{'/promotion/seckillgroupbuygoods/list/'+${secKillGroupBuyId}}"  th:object="${goodsSearch}"  method="post">
							<div class="form-group">
					            <select id="goodsBrandsId" name="goodsBrandsId" style="width:110px;" th:remove="none" class="form-control">
					            	<option value="">所有品牌</option>
					                <option th:each="eachValue : ${brands}" th:field="*{goodsBrandsId}" th:value="${eachValue.id}" th:text="${eachValue.name}"></option>
					            </select>	
					            <input type="hidden" id="hidden_goodsBrandsId" th:value="${goodsBrandsId}" />												
							</div>
							
							<div class="form-group">
					            <select id="goodsCategoryId" name="goodsCategoryId" style="width:110px;" th:remove="none" class="form-control">
					            	<option value="">所有分类</option>
					                <option th:each="eachValue : ${categorys}" th:field="*{goodsCategoryId}" th:value="${eachValue.id}" th:text="${eachValue.name}"></option>
					            </select>
					            <input type="hidden" id="hidden_goodsCategoryId" th:value="${goodsCategoryId}" />														
							</div>
		
							
							<div class="form-group">
							<label class="sr-only" for="keyword">keyword</label>
								<input type="text" name="keyword" style="width:80px;" th:field="*{keyword}" placeholder="关键字"  id="keyword" class="form-control" />
							</div>
	
							
							
							<button type="submit" id="bt_search" name="bt_search" class="btn green">
								<i class="fa  fa-search"></i>
							</button>
						</form>
						
						<form class="form-inline" th:action="@{'/promotion/seckillgroupbuygoods/uploadgoods/'+${secKillGroupBuyId}}"  th:object="${goodsFile}" enctype="multipart/form-data"
						  method="POST">
							<div class="form-group">
							<label class="sr-only" for="goodsFile">批量上传商品</label>
								<input type="File" name="goodsFile" th:field="*{goodsFile}" placeholder="上传文件"  id="goodsFile"  />
							</div>
							<button type="submit" id="bt_search" name="bt_search" class="btn green">
								<i class="fa  fa-plus">上传</i>
							</button>
						</form>
					</div>
					
					
					</div>
					<div id = "div_goods_grid" th:include="promotion/seckillgroupbuygoods/goods_table">
		
					</div>
					
			</div>
		</div>
	</div>
</div>	
</body>
</html>
